import Vue from 'vue'
import App from './App.vue'
import router from './router/router.js'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import { VueJsonp } from 'vue-jsonp'

Vue.use(ElementUI);
Vue.use(VueJsonp);

Vue.prototype.$axios = axios
// axios.defaults.baseURL = 'http://39.103.189.178:8888'
axios.defaults.baseURL = 'http://127.0.0.1:8888'
axios.defaults.changeOrigin = true
axios.defaults.withCredentials = true
axios.defaults.allowCredentials = true

Vue.prototype.$axios2 = axios.create({
    timeout: 15000,
    baseURL: "http://106.12.155.7:80",
	changeOrigin : true,
	withCredentials : true,
	allowCredentials : true,
});

Vue.config.productionTip = false

axios.interceptors.request.use(function (config) {
    let token = window.localStorage.getItem("mcsittoken")
	
    // if (token) {
        config.headers['mcsittoken'] = token;    //将token放到请求头发送给服务器
    // }
	return config;
}, function (error) {
    // Do something with request error
    return Promise.reject(error);
});
axios.interceptors.response.use(res => {
    
    // 该返回的数据则是axios.then(res)中接收的数据
    return res
}, err => {
   
    // 该返回的数据则是axios.catch(err)中接收的数据
    return Promise.reject(err)
})


new Vue({
	router,
	render: h => h(App),
}).$mount('#app')
